package com.lonty.intelligence.service;

import com.lonty.intelligence.mapper.LicensePlateMapper;
import com.lonty.intelligence.model.LicensePlate;
import com.lonty.intelligence.util.UUIDUtil;
import com.lonty.intelligence.vo.LicensePlateVo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * @Author 陈璇
 * @Date 2020/5/11 14:15
 * @Version 1.0
 */
@Service
public class LicensePlateService {

    @Resource
    private LicensePlateMapper licensePlateMapper;

    /**
     * 保存车牌
     * @param licensePlateVo
     * @return
     */
    public LicensePlate saveLicensePlate(LicensePlateVo licensePlateVo){
        LicensePlate licensePlate = new LicensePlate();
        BeanUtils.copyProperties(licensePlateVo, licensePlate);
        licensePlate.setId(UUIDUtil.randomID());
        licensePlate.setIsDel(0);
        if(licensePlateMapper.saveLicensePlate(licensePlate) > 0){
            return licensePlate;
        }
        return null;
    }

    /**
     * 根据住户ID获取车牌
     * @param householdId
     * @return
     */
    public List<LicensePlate> getByHouseholdId(String householdId){
        return licensePlateMapper.getByHouseholdId(householdId);
    }

}
